﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using BCNPCObject.DB;
using DbLinq;
using DbLinq.Oracle;
using CMISLibrary.Entities;
using CMISLibrary;

namespace BCNPCObject
{
    public class cls_NPC_KHTTTT_Controller
    {
        #region   Atributes

        private DataSet CMIS_Header = new CMISOutputParameter();
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();
        private NPC_KHTTTT info;

        #endregion

        #region   Constructor

        public cls_NPC_KHTTTT_Controller()
        {
            info = new NPC_KHTTTT();
        }
        public cls_NPC_KHTTTT_Controller(NPC_KHTTTT Info)
        {
            this.info = Info;
        }

        #endregion

        #region   Properties

        public NPC_KHTTTT pInfor
        {
            get { return info; }
            set { info = value; }
        }

        #endregion

        #region  DungNT NPC

        public IEnumerable<NPC_KHTTTT> Get_NPC_KHTTTT(string p_madonvi)
        {
            //DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            try
            {
                CMIS2.ResetDB();
                var q = from p in CMIS2.DB.NPC_KHTTTT
                        where p.MA_DVIQLY == p_madonvi
                        orderby p.MA_LO
                        select p;
                   
                return q;
            }
            catch
            {
                CMIS2.ResetDB();
                return null;
            }
        }
        public bool update_KHTTTT()
        {
            try
            {
                NPC_KHTTTT obj_NPC_KHTTTT = CMIS2.DB.NPC_KHTTTT.Single(c => c.MA_DVIQLY == info.MA_DVIQLY && c.MA_LO == pInfor.MA_LO);
                obj_NPC_KHTTTT.DL_MBA = pInfor.DL_MBA;
                obj_NPC_KHTTTT.CHIEU_DAI = pInfor.CHIEU_DAI;
                obj_NPC_KHTTTT.TIET_DIEN = pInfor.TIET_DIEN;
                obj_NPC_KHTTTT.TTKT_KH = pInfor.TTKT_KH;
                obj_NPC_KHTTTT.TCHIEU_DAI = pInfor.TCHIEU_DAI;
                CMIS2.DB.NPC_KHTTTT.UpdateOnSubmit(obj_NPC_KHTTTT);
                return true;
            }
            catch
            { return false; }
        }
        #endregion
    }


}
